home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Periodicals / develop / develop 8 code / TValidText / UDateTimeUtilities.p < prev    next >
Encoding:
Text File  |  1991-10-09  |  3.2 KB  |  107 lines  |  [TEXT/MPS ]

  1. {*******************************************************************************
  2. UDateTimeUtilities.p
  3.     This file contains the implementations of a number of routines which help
  4.     make the Script Manager more useable.
  5. *******************************************************************************}
  6.  
  7. UNIT UDateTimeUtilities;
  8.  
  9. INTERFACE
  10. USES
  11.     { • MacApp }
  12.     UMacApp,
  13.     UMacAppUtilities,
  14.     
  15.     { • Implementation use }
  16.     ToolUtils,
  17.     Packages,
  18.     Script;
  19.  
  20. CONST
  21.     kNotADate            =     -0;        { a comp NaN (a LongDateTime is a comp) }
  22.     kNotATime            =     $FFFFFFFF;    { the maximum unsigned longint value }
  23.     
  24.     kWantSeconds        =  TRUE;        { for time to string operations }
  25.     kDontWantSeconds    = FALSE;        { for time to string operations }
  26.     
  27.     kSecsPerMinute        =     60;        { number of seconds in a minute }
  28.     kSecsPerHour        =    60 * kSecsPerMinute;    { seconds in a hour }
  29.     kSecsPerDay            =    24 * kSecsPerHour;        { seconds in a day }
  30.  
  31.     {###########################################################################
  32.     Initialization
  33.         This routine MUST be called to initialize this unit.  Call it AFTER
  34.         MacApp has been initialized.  When it is initialized relative to the
  35.         other MacApp building blocks does not matter.
  36.     ###########################################################################}
  37.     
  38.     PROCEDURE InitUDateTimeUtilities;
  39.     
  40.  
  41.     {###########################################################################
  42.     Global Routines
  43.         In these routines, a LongDateTime is used to represent a date in a
  44.         compact form, while a LONGINT is used to represent a time in a compact
  45.         form.
  46.         
  47.         In both cases, a LongDateRec is used to represent the type's expanded
  48.         form.
  49.     ###########################################################################}
  50.     
  51.     PROCEDURE InitLongDateRec(
  52.                         VAR    dateRec:        LongDateRec;
  53.                             toValue:        INTEGER);
  54.         { Places the given value in each field of the given rec }
  55.         
  56.     PROCEDURE SecsToRec(
  57.                             dateSecs:        LongDateTime;
  58.                         VAR    dateRec:        LongDateRec);
  59.         { Makes the given LongDateRec match the given LongDateTime. }
  60.  
  61.     PROCEDURE RecToSecs(
  62.                         VAR    dateRec:        LongDateRec;    { not changed }
  63.                         VAR    dateSecs:        LongDateTime);
  64.         { Makes the given LongDateTime match the given LongDateRec. }
  65.  
  66.     PROCEDURE DateToString(
  67.                             dateSecs:        LongDateTime;
  68.                             theDateForm:    DateForm;
  69.                         VAR    theDate:        Str255);
  70.         { Makes the given string match the given LongDateTime. }
  71.                         
  72.     PROCEDURE TimeToString(
  73.                             timeSecs:        LONGINT;
  74.                             wantSeconds:    BOOLEAN;
  75.                         VAR    theTime:        Str255);
  76.         { Makes the given string match the given time. }
  77.  
  78.     FUNCTION  StringToDate(
  79.                             dateStr:        Str255;
  80.                         VAR    dateSecs:        LongDateTime)
  81.                             :String2DateStatus;
  82.         { Makes the given LongDateTime match the given string. }
  83.                         
  84.     FUNCTION  StringToTime(
  85.                             timeStr:        Str255;
  86.                         VAR    timeSecs:        LONGINT)
  87.                             :String2DateStatus;
  88.         { Makes the given time match the given string. }
  89.                         
  90.     FUNCTION  LongDateTimeToTime(
  91.                         VAR    dateSecs:        LongDateTime)
  92.                             :LONGINT;
  93.         { This routine extracts the current time from the given LongDateTime. }
  94.     
  95.     PROCEDURE GetCurrentDate(
  96.                         VAR    dateSecs:        LongDateTime);
  97.         { Returns today's date. }
  98.     
  99.     PROCEDURE GetCurrentTime(
  100.                         VAR    timeSecs:        LONGINT);
  101.         { Returns the current time. }
  102.  
  103. IMPLEMENTATION
  104.  
  105. {$I UDateTimeUtilities.inc1.p}
  106.  
  107. END.  { UDateTimeUtilities.p }